package org.dk.poitalk.model;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

import com.google.appengine.api.datastore.Key;

@Entity
@NamedQueries({
	@NamedQuery(name="Reward.findByName", query="SELECT r FROM Reward r WHERE r.name = :name"),
	@NamedQuery(name="Reward.findAll", query="SELECT r FROM Reward r")
})
public class Reward extends DomainUserEntityImpl implements Serializable {

	private String name;

	/**
	 * Constructor
	 * @param id id
	 * @param name name
	 */
	public Reward(Key id, String name) {
		super();
		this.setKey(id);
		this.name = name;
	}

	/**
	 * Constructor vacio
	 */
	public Reward() {
		super();
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	@Override
	public String toString() {
		return "Reward [" + super.toString() + ", name=" + this.name + "]";
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder()
			.appendSuper(super.hashCode())
			.append(this.name)
			.hashCode();
	}

	@Override
	public boolean equals(final Object other) {
		if (!(other instanceof Reward)) {
			return false;
		}
		Reward castOther = (Reward) other;
		return new EqualsBuilder()
			.appendSuper(super.equals(castOther))
			.append(this.name, castOther.name)
			.isEquals();
	}
}